﻿using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;

namespace CoreEx.ServiceModel
{
    /// <summary>
    /// Provides a base class for implementing the <see cref="IInitializer{TTarget}"/> interface.
    /// </summary>
    /// <typeparam name="TTarget"></typeparam>
    public abstract class InitializerBase<TTarget> : IInitializer<TTarget>, IInitialize
    {
        /// <summary>
        /// Gets the <see cref="IServiceContainer"/> instance. 
        /// </summary>
        protected IServiceContainer ServiceContainer { get; private set; }

        /// <summary>
        /// Initializes the <paramref name="target"/> instance.
        /// </summary>
        /// <param name="target"></param>
        public abstract void Initialize(TTarget target);
        
        /// <summary>
        /// Initializes this service instance.
        /// </summary>        
        public virtual void Initialize(IServiceContainer source)
        {
            ServiceContainer = source;
        }
    }
}
